<extend name="template/base_index" />
<block name="area_header">
    <link rel="stylesheet" href="__CSS__/userinfo.css">
</block>
<block name="area_body">
<form id="addre_form" method="post" action="{:U('Address/addre_edit')}">
    <input type="hidden" name="id" value="{$id}">
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">收货人</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" type="text" name="contactname" value="{$contactname}">
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">联系电话</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" type="text" name="mobile" value="{$mobile}">
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">所在地区</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input type="text" id='city-picker' class="weui_input" name="address" value="{$province} {$city} {$area}"/>
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label">详细地址</label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input type="text"  class="weui_input" placeholder="请输入" name="detailinfo" value="{$detailinfo}"/>
            </div>
        </div>
    </div>
    <a href="javascript:;" class="weui_btn weui_btn_warn save_button" onclick="validate_form()">保存</a>
</form>
    <script src="__JS__/jquery-weui.min.js"></script>
    <script type="text/javascript" src="__JS__/city-picker.min.js" charset="utf-8"></script>
    <script>
        $("#city-picker").cityPicker({
            title: "请选择收货地址"
        });
        //提交前进行表单验证
       function validate_form(){
           if($("[name='contactname']").val() !='' && $("[name='mobile']").val() !='' && $("[name='address']").val() != ''&& $("[name='addre_detail']").val() != ''){
                $('#addre_form').submit();
           }else{
               $.toast('表单填写有误');
           }
       }
    </script>
</block>